/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-04-14 21:08:58
 * @LastEditTime: 2024-06-30 12:15:03
 * @FilePath: /nest_study/web/src/views/system/menu/columns.tsx
 */
import { Button, Flex } from "antd";
import { isExternalTypes, isShowMenu, menuTypes } from "./dictionary";
import ShowDictionary from "@/components/dictionary_label";
import IconSvg from "@/components/icon_svg";

export const columns = (edit: Function, remove: Function) => [
    {
        title: '菜单名称',
        dataIndex: 'name',
        ellipsis: true
    },
    {
        title: '菜单类型',
        dataIndex: 'menuType',
        ellipsis: true,
        width: 120,
        render: (text: any, _row: any, _index: number) => <ShowDictionary list={menuTypes} label={'label'} value={text} />,
    },
    {
        title: '菜单图标',
        dataIndex: 'icon',
        ellipsis: true,
        width: 120,
        render: (value: string, _record: any, _index: any) => {
            return <IconSvg name={value} />
        },
    },
    {
        title: '菜单/权限',
        dataIndex: 'path',
        ellipsis: true
    },
    {
        title: '是否为外链',
        dataIndex: 'external',
        ellipsis: true,
        width: 120,
        render: (text: any, _row: any, _index: number) => <ShowDictionary list={isExternalTypes} label={'label'} value={text} />,
    },
    {
        title: '是否显示',
        dataIndex: 'visible',
        ellipsis: true,
        width: 120,
        render: (text: any, _row: any, _index: number) => <ShowDictionary list={isShowMenu} label={'label'} value={text} />,
    },
    {
        title: '排序',
        dataIndex: 'sort',
        ellipsis: true,
        width: 120,
    },
    {
        title: '操作',
        dataIndex: 'action',
        width: 120,
        align: "center" as "center",
        fixed: 'right' as 'right',
        render: (_text: any, _row: any, _index: number) => <Flex gap={10} align="center">
            <Button size="small" type="primary" onClick={() => edit(_row)}>编辑</Button>
            <Button size="small" type="primary" onClick={() => remove(_row)} danger>删除</Button>
        </Flex>,
    }
]